#ifndef RECENTFILESCONTROLLER_H
#define RECENTFILESCONTROLLER_H

#include <QObject>
#include "RecentFilesViewObserver.h"
class RecentFiles;
class RecentFilesView;

class RecentFilesController : public QObject, public RecentFilesViewObserver
{
Q_OBJECT

public:
    explicit RecentFilesController(RecentFiles& model, RecentFilesView& view, QObject *parent = 0);

    /**
      * Loads the recent files data into the model.
      */
    void load();

    /**
      * This should be called when a file is opened.
      * @param filename The name of the file that was opened.
      */
    void onOpen(const QString& filename);

    /**
      * This should be called when a file is saved.
      * @param filename The name of the file being saved.
      */
    void onSave(const QString& filename);

    /**
      * Called from a RecentFilesView object.
      * @param filename A recent file has been selected in the view.
      */
    virtual void recentFileSelected(const QString& filename);

    /**
      * Saves the recent files.
      */
    void save();

signals:
    void signalRecentFileSelected(const QString& filename);

private:

    /** The recent files data is the model. */
    RecentFiles& m_model;

    /** The view which displays the recent files data. */
    RecentFilesView& m_view;
};

#endif // RECENTFILESCONTROLLER_H
